package com.help10000.rms.common

import com.google.common.util.concurrent.ThreadFactoryBuilder
import java.util.concurrent.*

class ExecutorServiceManager {
    // 文件相关的线程池,比如,加载网络图片,读取文件,操作数据库,下载文件等,
    companion object {
        val CACHE_THREAD_EXECUTOR: ExecutorService = ThreadPoolExecutor(
            5,
            200,
            30L,
            TimeUnit.MILLISECONDS,
            LinkedBlockingQueue(1024),
            ThreadFactoryBuilder().setNameFormat("cached-thread-%d").build(),
            ThreadPoolExecutor.DiscardPolicy()
        )
        val SINGLE_THREAD_EXECUTOR: ExecutorService = ThreadPoolExecutor(
            1,
            1,
            30L,
            TimeUnit.MILLISECONDS,
            LinkedBlockingQueue(1024),
            ThreadFactoryBuilder().setNameFormat("single-thread-%d").build(),
            ThreadPoolExecutor.DiscardPolicy()
        )

        val SCHEDULE_THREAD_EXECUTOR: ScheduledThreadPoolExecutor = ScheduledThreadPoolExecutor(
            1,
            ThreadFactoryBuilder().setNameFormat("schedule-thread-%d").build()
        )
    }


}